package com.yang.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yang.dto.req.UserPageQueryReqDTO;
import com.yang.dto.resp.UserPageQueryRespDTO;
import com.yang.result.Result;
import com.yang.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户业务逻辑层
 * 作者：孤城暖阳y
 * 开发时间：2025-02-26
 */
@RestController
@RequiredArgsConstructor
@Tag(name = "用户管理")
public class UserController {

    private final UserService userService;

    @Operation(summary = "用户信息获取")
    @GetMapping("/Treasure-Pavilion-admin/user/page")
    public Result<IPage<UserPageQueryRespDTO>> findAll(UserPageQueryReqDTO requestParam) {
        return Result.success(userService.pageQueryUser(requestParam));
    }

    @Operation(summary = "用户信息删除")
    @PostMapping("/Treasure-Pavilion-admin/user/delete/{userId}")
    public Result delete(@PathVariable Long userId) {
        userService.deleteUser(userId);
        return Result.success();
    }
}
